Slides: Convolutional Neural Networks (20 min)

Open In Colab

Slides: Convolutional Neural Networks (20 min)#

Use Presentation mode.

  • Convolutions

  • Pooling

  • U-Net

  • Microscopy use cases

  • Teaching methods

import numpy as np
import matplotlib.pyplot as plt

from ttt_workshop_cnn import utils
from IPython.display import HTML

Under the hood of CNNs#

# %matplotlib widget
smiley = utils.draw_smiley()
kernel = utils.draw_gaussian_kernel(size=3, sigma=1)
animation = utils.animate_convolution(smiley, kernel, interval=200)
HTML(animation.to_jshtml())
../_images/f94316f38e4cc3c44c1a36f3ff406c30a459ed8219212591314d348d57476ec6.png

Note how the output is smaller than the input. This can be avoided using padding

Padding#

padded_smiley = np.pad(smiley, pad_width=1, mode='constant', constant_values=0)
padded_animation = utils.animate_convolution(padded_smiley, kernel, interval=200)
HTML(padded_animation.to_jshtml())
../_images/916f0b898a0430c02fc73aaf5831a57f3a4a768af050e05f0011119964da19d4.png
padded_smiley = np.pad(smiley, pad_width=1, mode='reflect')
padded_animation = utils.animate_convolution(padded_smiley, kernel, interval=200)
HTML(padded_animation.to_jshtml())
../_images/55e550eac0abe68d6c7b4499d51c0b5deea6b25d2269d756739133867795ddb1.png
padded_smiley = np.pad(smiley, pad_width=1, mode='wrap')
padded_animation = utils.animate_convolution(padded_smiley, kernel, interval=200)
HTML(padded_animation.to_jshtml())
../_images/0a339c9b4a5769a95aabb0992ef56d6ee02dab76b3eb85bad7a0ffe9fe4260b2.png